using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;
using System.Web;
using System.Threading;

namespace Data
{
	/// <summary>
	/// Strongly-typed collection for the forum class.
	/// </summary>
	[Serializable]
	public partial class forumCollection : ActiveList<forum, forumCollection> 
	{	   
		public forumCollection() {}

	}

	/// <summary>
	/// This is an ActiveRecord class which wraps the forum table.
	/// </summary>
	[Serializable]
	public partial class forum : ActiveRecord<forum>
	{
		#region .ctors and Default Settings
		
		public forum()
		{
		  SetSQLProps();
		  InitSetDefaults();
		  MarkNew();
		}

		
		private void InitSetDefaults() { SetDefaults(); }

		
		public forum(bool useDatabaseDefaults)
		{
			SetSQLProps();
			if(useDatabaseDefaults)
				ForceDefaults();
			MarkNew();
		}

		public forum(object keyID)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByKey(keyID);
		}

		 
		public forum(string columnName, object columnValue)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByParam(columnName,columnValue);
		}

		
		protected static void SetSQLProps() { GetTableSchema(); }

		
		#endregion
		
		#region Schema and Query Accessor
		public static Query CreateQuery() { return new Query(Schema); }

		
		public static TableSchema.Table Schema
		{
			get
			{
				if (BaseSchema == null)
					SetSQLProps();
				return BaseSchema;
			}

		}

		
		private static void GetTableSchema() 
		{
			if(!IsSchemaInitialized)
			{
				//Schema declaration
				TableSchema.Table schema = new TableSchema.Table("forum", TableType.Table, DataService.GetInstance("MyProvider"));
				schema.Columns = new TableSchema.TableColumnCollection();
				schema.SchemaName = @"";
				//columns
				
				TableSchema.TableColumn colvarID = new TableSchema.TableColumn(schema);
				colvarID.ColumnName = "ID";
				colvarID.DataType = DbType.String;
				colvarID.MaxLength = 40;
				colvarID.AutoIncrement = false;
				colvarID.IsNullable = false;
				colvarID.IsPrimaryKey = true;
				colvarID.IsForeignKey = false;
				colvarID.IsReadOnly = false;
				colvarID.DefaultSetting = @"";
				colvarID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarID);
				
				TableSchema.TableColumn colvarFullName = new TableSchema.TableColumn(schema);
				colvarFullName.ColumnName = "FullName";
				colvarFullName.DataType = DbType.String;
				colvarFullName.MaxLength = 125;
				colvarFullName.AutoIncrement = false;
				colvarFullName.IsNullable = false;
				colvarFullName.IsPrimaryKey = false;
				colvarFullName.IsForeignKey = false;
				colvarFullName.IsReadOnly = false;
				colvarFullName.DefaultSetting = @"";
				colvarFullName.ForeignKeyTableName = "";
				schema.Columns.Add(colvarFullName);
				
				TableSchema.TableColumn colvarEmail = new TableSchema.TableColumn(schema);
				colvarEmail.ColumnName = "Email";
				colvarEmail.DataType = DbType.String;
				colvarEmail.MaxLength = 125;
				colvarEmail.AutoIncrement = false;
				colvarEmail.IsNullable = true;
				colvarEmail.IsPrimaryKey = false;
				colvarEmail.IsForeignKey = false;
				colvarEmail.IsReadOnly = false;
				colvarEmail.DefaultSetting = @"";
				colvarEmail.ForeignKeyTableName = "";
				schema.Columns.Add(colvarEmail);
				
				TableSchema.TableColumn colvarRating = new TableSchema.TableColumn(schema);
				colvarRating.ColumnName = "Rating";
				colvarRating.DataType = DbType.Int32;
				colvarRating.MaxLength = 11;
				colvarRating.AutoIncrement = false;
				colvarRating.IsNullable = true;
				colvarRating.IsPrimaryKey = false;
				colvarRating.IsForeignKey = false;
				colvarRating.IsReadOnly = false;
				colvarRating.DefaultSetting = @"";
				colvarRating.ForeignKeyTableName = "";
				schema.Columns.Add(colvarRating);
				
				TableSchema.TableColumn colvarContent = new TableSchema.TableColumn(schema);
				colvarContent.ColumnName = "Content";
				colvarContent.DataType = DbType.String;
				colvarContent.MaxLength = 1000;
				colvarContent.AutoIncrement = false;
				colvarContent.IsNullable = true;
				colvarContent.IsPrimaryKey = false;
				colvarContent.IsForeignKey = false;
				colvarContent.IsReadOnly = false;
				colvarContent.DefaultSetting = @"";
				colvarContent.ForeignKeyTableName = "";
				schema.Columns.Add(colvarContent);
				
				TableSchema.TableColumn colvarParentID = new TableSchema.TableColumn(schema);
				colvarParentID.ColumnName = "ParentID";
				colvarParentID.DataType = DbType.String;
				colvarParentID.MaxLength = 500;
				colvarParentID.AutoIncrement = false;
				colvarParentID.IsNullable = true;
				colvarParentID.IsPrimaryKey = false;
				colvarParentID.IsForeignKey = false;
				colvarParentID.IsReadOnly = false;
				colvarParentID.DefaultSetting = @"";
				colvarParentID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarParentID);
				
				TableSchema.TableColumn colvarStatus = new TableSchema.TableColumn(schema);
				colvarStatus.ColumnName = "Status";
				colvarStatus.DataType = DbType.Int32;
				colvarStatus.MaxLength = 11;
				colvarStatus.AutoIncrement = false;
				colvarStatus.IsNullable = true;
				colvarStatus.IsPrimaryKey = false;
				colvarStatus.IsForeignKey = false;
				colvarStatus.IsReadOnly = false;
				colvarStatus.DefaultSetting = @"";
				colvarStatus.ForeignKeyTableName = "";
				schema.Columns.Add(colvarStatus);
				
				TableSchema.TableColumn colvarActive = new TableSchema.TableColumn(schema);
				colvarActive.ColumnName = "Active";
				colvarActive.DataType = DbType.Boolean;
				colvarActive.MaxLength = 1;
				colvarActive.AutoIncrement = false;
				colvarActive.IsNullable = true;
				colvarActive.IsPrimaryKey = false;
				colvarActive.IsForeignKey = false;
				colvarActive.IsReadOnly = false;
				colvarActive.DefaultSetting = @"";
				colvarActive.ForeignKeyTableName = "";
				schema.Columns.Add(colvarActive);
				
				TableSchema.TableColumn colvarCreatedDate = new TableSchema.TableColumn(schema);
				colvarCreatedDate.ColumnName = "CreatedDate";
				colvarCreatedDate.DataType = DbType.DateTime;
				colvarCreatedDate.MaxLength = 0;
				colvarCreatedDate.AutoIncrement = false;
				colvarCreatedDate.IsNullable = true;
				colvarCreatedDate.IsPrimaryKey = false;
				colvarCreatedDate.IsForeignKey = false;
				colvarCreatedDate.IsReadOnly = false;
				colvarCreatedDate.DefaultSetting = @"";
				colvarCreatedDate.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCreatedDate);
				
				TableSchema.TableColumn colvarUpdatedDate = new TableSchema.TableColumn(schema);
				colvarUpdatedDate.ColumnName = "UpdatedDate";
				colvarUpdatedDate.DataType = DbType.DateTime;
				colvarUpdatedDate.MaxLength = 0;
				colvarUpdatedDate.AutoIncrement = false;
				colvarUpdatedDate.IsNullable = true;
				colvarUpdatedDate.IsPrimaryKey = false;
				colvarUpdatedDate.IsForeignKey = false;
				colvarUpdatedDate.IsReadOnly = false;
				colvarUpdatedDate.DefaultSetting = @"";
				colvarUpdatedDate.ForeignKeyTableName = "";
				schema.Columns.Add(colvarUpdatedDate);
				
				BaseSchema = schema;
				//add this schema to the provider
				//so we can query it later
				DataService.Providers["MyProvider"].AddSchema("forum",schema);
			}

		}

		#endregion
		
		#region Props
		
		  
		[XmlAttribute("ID")]
		public string ID 
		{
			get { return GetColumnValue<string>("ID"); }

			set { SetColumnValue("ID", value); }

		}

		  
		[XmlAttribute("FullName")]
		public string FullName 
		{
			get { return GetColumnValue<string>("FullName"); }

			set { SetColumnValue("FullName", value); }

		}

		  
		[XmlAttribute("Email")]
		public string Email 
		{
			get { return GetColumnValue<string>("Email"); }

			set { SetColumnValue("Email", value); }

		}

		  
		[XmlAttribute("Rating")]
		public int? Rating 
		{
			get { return GetColumnValue<int?>("Rating"); }

			set { SetColumnValue("Rating", value); }

		}

		  
		[XmlAttribute("Content")]
		public string Content 
		{
			get { return GetColumnValue<string>("Content"); }

			set { SetColumnValue("Content", value); }

		}

		  
		[XmlAttribute("ParentID")]
		public string ParentID 
		{
			get { return GetColumnValue<string>("ParentID"); }

			set { SetColumnValue("ParentID", value); }

		}

		  
		[XmlAttribute("Status")]
		public int? Status 
		{
			get { return GetColumnValue<int?>("Status"); }

			set { SetColumnValue("Status", value); }

		}

		  
		[XmlAttribute("Active")]
		public bool? Active 
		{
			get { return GetColumnValue<bool?>("Active"); }

			set { SetColumnValue("Active", value); }

		}

		  
		[XmlAttribute("CreatedDate")]
		public DateTime? CreatedDate 
		{
			get { return GetColumnValue<DateTime?>("CreatedDate"); }

			set { SetColumnValue("CreatedDate", value); }

		}

		  
		[XmlAttribute("UpdatedDate")]
		public DateTime? UpdatedDate 
		{
			get { return GetColumnValue<DateTime?>("UpdatedDate"); }

			set { SetColumnValue("UpdatedDate", value); }

		}

		
		#endregion
		
		
			
		
		//no foreign key tables defined (0)
		
		
		
		//no ManyToMany tables defined (0)
		
		#region ObjectDataSource support
		
		
		/// <summary>
		/// Inserts a record, can be used with the Object Data Source
		/// </summary>
		public static void Insert(string varID,string varFullName,string varEmail,int? varRating,string varContent,string varParentID,int? varStatus,bool? varActive,DateTime? varCreatedDate,DateTime? varUpdatedDate)
		{
			forum item = new forum();
			
			item.ID = varID;
			
			item.FullName = varFullName;
			
			item.Email = varEmail;
			
			item.Rating = varRating;
			
			item.Content = varContent;
			
			item.ParentID = varParentID;
			
			item.Status = varStatus;
			
			item.Active = varActive;
			
			item.CreatedDate = varCreatedDate;
			
			item.UpdatedDate = varUpdatedDate;
			
		
			if (HttpContext.Current != null)
				item.Save(HttpContext.Current.User.Identity.Name);
			else
				item.Save(Thread.CurrentPrincipal.Identity.Name);
		}

		
		/// <summary>
		/// Updates a record, can be used with the Object Data Source
		/// </summary>
		public static void Update(string varID,string varFullName,string varEmail,int? varRating,string varContent,string varParentID,int? varStatus,bool? varActive,DateTime? varCreatedDate,DateTime? varUpdatedDate)
		{
			forum item = new forum();
			
				item.ID = varID;
				
				item.FullName = varFullName;
				
				item.Email = varEmail;
				
				item.Rating = varRating;
				
				item.Content = varContent;
				
				item.ParentID = varParentID;
				
				item.Status = varStatus;
				
				item.Active = varActive;
				
				item.CreatedDate = varCreatedDate;
				
				item.UpdatedDate = varUpdatedDate;
				
			item.IsNew = false;
			if (HttpContext.Current != null)
				item.Save(HttpContext.Current.User.Identity.Name);
			else
				item.Save(Thread.CurrentPrincipal.Identity.Name);
		}

		#endregion
		#region Columns Struct
		public struct Columns
		{
			int i;
			 public static string ID = @"ID";
			 public static string FullName = @"FullName";
			 public static string Email = @"Email";
			 public static string Rating = @"Rating";
			 public static string Content = @"Content";
			 public static string ParentID = @"ParentID";
			 public static string Status = @"Status";
			 public static string Active = @"Active";
			 public static string CreatedDate = @"CreatedDate";
			 public static string UpdatedDate = @"UpdatedDate";
						
		}

		#endregion
	}

}

